home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 224 < prev    next >
Internet Message Format  |  1996-08-06  |  4KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c,comp.std.c
  4. Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
  5. Date: Mon, 29 Jan 96 23:37:46 GMT
  6. Organization: none
  7. Message-ID: <822958666snz@genesis.demon.co.uk>
  8. References: <30C40F77.53B5@swsbbs.com> <SPENCER.96Jan22113215@zorgon.ERA.COM> <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
  15.            kanze@lts.sel.alcatel.de "James Kanze US/ESC 60/3/141 #40763" writes:
  16.  
  17. >I think the crux of Michael Furman's question lies therein.  Does the
  18. >standard require a diagnostic if the function main is not of one of
  19. >the two types given?
  20.  
  21. No, that is neither a syntax error (or at least need not be) or a violation
  22. of a rule in a constraints section so no diagnostic is required.
  23.  
  24. >To tell the truth, I'm not sure what the answer is.  The text
  25. >concerning main is in the chapter describing the environment.  It
  26. >doesn't appear as a semantic restriction or anything.  It simply
  27. >states that on start-up, a function called main will be called, and
  28. >that the implementation must support the following forms.  It doesn't
  29. >seem (to me, at least) to say anything about what other forms it might
  30. >support, or what the implementation must do if given a fully other
  31. >definition of main.
  32.  
  33. The standard defines the behaviour of 2 stated forms of main (and
  34. semantically equivalent forms). It doesn't define any behaviour for any
  35. other forms therefore those other forms result in undefined behaviour -
  36. from 3.16:
  37.  
  38. "If a ``shall'' or ``shall not'' requirement that appears outside of
  39.  a constraint is violated, the behaviour is undefined. Undefined behaviour
  40.  is otherwise indicated by the words ``undefined behaviour'' or by the
  41.  omission of any explicit definition of behaviour. There is no difference
  42.  in emphasis among these three; they all describe ``behaviour that is
  43.  undefined''".
  44.  
  45. Other forms of main are an example of "omission of any explicit definition
  46. of behaviour" and by the last sentence have the same effect as any other
  47. form of undefined behaviour.
  48.  
  49. >Normally, I would expect (at the very least) a compiler to generate a
  50. >warning or an error for a main that it did not support.
  51.  
  52. There is no requirement for that. Indeed that allows useful implementation
  53. extensions without making the compiler non-conforming. Of course such
  54. extensions are non-portable.
  55.  
  56. >In fact,
  57. >however, my compiler (gcc) accepts the following definition without
  58. >the slightest complaint, although I'd rather not think about what will
  59. >happen when I access parameter d:
  60. >
  61. >        int main( char a , int b , long c , double d )
  62.  
  63. main is something that the language leaves up to the programmer to get
  64. right.
  65.  
  66. >|> For purposes of the C newsgroups, discussion of what is/isn't legal
  67. >|> is generally restricted to strictly conforming C.
  68. >
  69. >Yes and no.  In comp.std.c, the discussion is exactly about what is
  70. >legal according to the standard.  In comp.lang.c (to which this
  71. >article is also cross-posted), the discussion should generally be a
  72. >bit more open.
  73. >
  74. >Thus, for example, in comp.std.c, a program with a variable named far
  75. >is illegal, and that is it.
  76.  
  77. I assume that was a typo (or thinko!) for "legal".
  78.  
  79. >In comp.lang.c (and I hope in its
  80. >moderated variant), I would hope that someone would point out that,
  81. >legal or not, it's going to get you into trouble.
  82.  
  83. Makes sense. 
  84.  
  85. -- 
  86. -----------------------------------------
  87. Lawrence Kirby | fred@genesis.demon.co.uk
  88. Wilts, England | 70734.126@compuserve.com
  89. -----------------------------------------
  90.